Skip to content

Changes to render full information on alarm tree non-leaf nodes. Also… - #3910

Merged
georgweiss merged 3 commits into
masterfrom
CSSTUDIO-2337b
Aug 20, 2026
Merged

Changes to render full information on alarm tree non-leaf nodes. Also…#3910
georgweiss merged 3 commits into
masterfrom
CSSTUDIO-2337b

Conversation

@georgweiss

Copy link
Copy Markdown
Collaborator

This is a follow up on #3880, aiming at reducing code complexity while also updating the alarm tree view to provide more information on non-leaf nodes.

Suggestion is to show full information on non-leaf nodes:

  • The total PV (leaf) count in sub-structure.
  • Number of leaves disabled without enable date, if any
  • Number of leaves disabled with enable date, if any
  • The enable date if the same for all leaves with enable date.

Screenshots below.

The view may become a bit cluttered as shown in the first example. However, the second example should probably reflect a more realistic scenario.

Screenshot 2026-08-19 at 08 57 42 Screenshot 2026-08-19 at 09 29 03
  • Testing:

    • [ X] The feature has automated tests
    • [ X] Tests were run
  • Documentation:

    • The feature is documented
    • [ X] The documentation is up to date

@georgweiss

Copy link
Copy Markdown
Collaborator Author

@shroffk, any objections to merging this?

protected static Set<AlarmClientLeaf> getLeafItems(List<AlarmTreeItem<?>> items){
Set<AlarmClientLeaf> leaves = new HashSet<>();
items.forEach(item -> leaves.addAll(getLeafItems(item)));
return leaves;

@abrahamwolk abrahamwolk Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this results in much copying and allocation on the heap: every leaf is copied once per layer from the leaf in question to the root.

I think this and the next method (which takes as argument a AlarmTreeItem<?> root) can be combined into a method that takes only a final AlarmTreeItem<?> root as its argument, plus a helper method for traversing the tree, along the following lines:

    protected static Set<AlarmClientLeaf> getLeafItems(final AlarmTreeItem<?> root) {
        return streamLeafItems(root).collect(Collectors.toSet());
    }

    private static Stream<AlarmClientLeaf> streamLeafItems(final AlarmTreeItem<?> alarmTreeItem){
        if (alarmTreeItem instanceof AlarmClientLeaf alarmClientLeaf){
            return Stream.of(alarmClientLeaf);
        }
        else {
            return alarmTreeItem.getChildren().stream().flatMap(child -> streamLeafItems(child));
        }
    }

@georgweiss georgweiss Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every leaf is copied once

What does "copied" here mean? No new AlarmClientLeaf objects are created.
But maybe you mean new Set objects are created and AlarmClientLeaf references are copied over?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct: "copying" was inaccurate. I should have written "re-insertion" instead: a reference to every leaf is inserted into a HashSet once per layer from the leaf in question to the root, and each re-insertion (1) hashes the element and (2) allocates a node for the hash set.


protected static Set<AlarmClientLeaf> getLeafItems(final AlarmTreeItem<?> root){
Set<AlarmClientLeaf> leaves = new HashSet<>();
if(root instanceof AlarmClientLeaf){

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast can be made type safe:

if(root instanceof AlarmClientLeaf alarmClientLeaf) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will udate.

@sonarqubecloud

Copy link
Copy Markdown

@georgweiss
georgweiss merged commit f1c4c55 into master Aug 20, 2026
11 checks passed
@georgweiss
georgweiss deleted the CSSTUDIO-2337b branch August 20, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants